# -*- coding: utf-8 -*-
import threading

"""
线程安全的单例实现
这个实现使用了 threading.Lock 来确保多线程环境下的线程安全。
"""


class Singleton(object):
    _instance = None
    _lock = threading.Lock()

    def __new__(cls, *args, **kwargs):
        with cls._lock:
            if cls._instance is None:
                cls._instance = super(Singleton, cls).__new__(cls)
        return cls._instance
